package io.renren.modules.jxgk.controller;

import io.renren.common.annotation.SysLog;
import io.renren.common.utils.Constant;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;
import io.renren.modules.jxgk.entity.ClassScheduleEntity;
import io.renren.modules.jxgk.service.ClassScheduleService;
import io.renren.modules.sys.entity.SysUserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("schedule/")
public class ClassScheduleController {

    @Autowired
    ClassScheduleService classScheduleService;

    @RequestMapping("SelectAll")
    public List Select() {
        List<ClassScheduleEntity> cs=classScheduleService.Select();
        for(ClassScheduleEntity c:cs){
            System.out.println(c.getEnd());
            System.out.println(c.getStart());
        }
        return  cs;
    }
    @RequestMapping("Select")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);
        List<ClassScheduleEntity> cse = classScheduleService.queryList(query);
        int total = classScheduleService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(cse, total, query.getLimit(), query.getPage());

        return R.ok().put("page", pageUtil);
    }
    @RequestMapping("/Delete")
    public R delete(@RequestBody String[] indexs){
        classScheduleService.deleteBatch(indexs);
        return R.ok();
    }
    @RequestMapping("/Insert")
    public R save(@RequestBody ClassScheduleEntity cse){
        classScheduleService.save(cse);

        return R.ok();
    }
    @RequestMapping("/Info/{index}")
    public R info(@PathVariable("index") String index){
        ClassScheduleEntity cse = classScheduleService.queryObject(index);
            return R.ok().put("schedule", cse);
    }
    @SysLog("修改用户")
    @RequestMapping("/Update")
    public R update(@RequestBody ClassScheduleEntity cse){
        classScheduleService.update(cse);
        return R.ok();
    }


}